<template>
  <div class="sign">
    <!--标题-->
    <div class="logo">
      <img src="@/assets/logo.png" alt="logo">
    </div>
  <div class="main">
    <div class="title">
      <router-link   to='/login' tag="span">登录</router-link>
      <router-link class="active" to='/register' tag="span">注册</router-link>
    </div>

    <div class="sign-up-container">
      <el-form ref="userForm" :model="params">
        <el-form-item class="input-prepend" prop="userName" :rules="[{ required: true, message: '请输入你的用户名', trigger: 'blur' }]">
          <div>
            <el-input type="text" placeholder="用户名" v-model="params.userName"/>
          </div>
        </el-form-item>
        <el-form-item class="input-prepend" prop="password" :rules="[{ required: true, message: '请输入密码', trigger: 'blur' }]">
          <div>
            <el-input type="password" placeholder="设置密码" v-model="params.password"/>
          </div>
        </el-form-item>
        <el-form-item  >
          <div>
            <el-select class="input-prepend" v-model="params.sex" placeholder="性别">
              <el-option
                label="男"
                value="true">
              </el-option>
              <el-option
                label="女"
                value="false">
              </el-option>
            </el-select>
          </div>
        </el-form-item>

        <div class="btn">
          <input type="button" class="sign-up-button" value="注册" @click="submitRegister()">
        </div>
        <p class="sign-up-msg">
          点击 “注册” 即表示您同意并愿意遵守
          <br>
          <a target="_blank" href="http://www.jianshu.com/p/c44d171298ce">用户协议</a>
          和
          <a target="_blank" href="http://www.jianshu.com/p/2ov8x3">隐私政策</a> 。
        </p>
      </el-form>
      <!-- 更多注册方式 -->
      <div class="more-sign">
        <h6>社交帐号直接注册</h6>
        <ul>
          <li><a id="weixin" class="weixin" target="_blank" href="http://huaan.free.idcfengye.com/api/ucenter/wx/login"><i
            class="iconfont icon-weixin"/></a></li>
          <li><a id="qq" class="qq" target="_blank" href="#"><i class="iconfont icon-qq"/></a></li>
        </ul>
      </div>
    </div>
  </div>
  </div>
</template>

<script>


import registerApi from "../../api/register";

export default {
  data() {
    return {
      params: {
        userName: '',
        password: ''
      },
    }
  },
  methods: {

    submitRegister() {
      this.$refs['userForm'].validate((valid) => {
        if (valid) {
          registerApi.registerMember(this.params).then(response => {
            //提示注册成功
            this.$message({
              type: 'success',
              message: "注册成功"
            })
            this.$router.push({path: '/login'})
          })
        }
      })
    },

  }
}
</script>
<style scoped>
@import url('../../assets/css/sign.css');
@import url('../../assets/css/iconfont.css');
</style>
